package com.example.controller;

import com.example.entity.Course;
import com.example.service.CourseService;
import com.example.service.CourseServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @program: demo4
 * @description:
 * @author: ChengY
 * @create: 2024-04-26 23:14
 */
@RestController
@RequestMapping("/course")
public class CourseController {
    @Autowired
    private CourseService courseService;
    @GetMapping("/findAll")
    public List<Course> findAll(){
        return courseService.findAllCourse();
    }
    @GetMapping("/findById")
    public Course findById(@RequestParam Long id){
        return courseService.findCourseById(id);
    }
    @PostMapping("/insertCourse")
    public Course insertCourse(@RequestBody Course course){
        return courseService.insertCourse(course);
    }
    @PutMapping("/updateCourse")
    public Course updateAll(@RequestBody Course course){
        return courseService.updateCourse(course);
    }
    @DeleteMapping("/deleteCourse")
    public void deleteCourse(@RequestParam Long id){
        courseService.deleteCourse(id);
    }

}
